package com.hulk.ratel.web.interceptor;


import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author cmt  
* @E-mail:29572320@qq.com
* @version Create on:  2017年4月12日 下午2:18:39
* Class description
*/
@Slf4j
@Order(Ordered.HIGHEST_PRECEDENCE-1)
public class LimitInterceptor extends HandlerInterceptorAdapter {



    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        //TODO
        // 流量控制 默认关闭， 可以开启 GUAVA 或 REDIS 类型流控。



       log.debug("LimitInterceptor.postHandle");
        return super.preHandle(request, response, handler);
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {
        log.debug("LimitInterceptor.postHandle");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
        log.debug("LimitInterceptor.afterCompletion", ex);
    }

}
